<?
namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $rule =   [
        'username'  => 'require|min:5|max:20|alphaDash',
        'passwd'   => 'require|min:6|alphaDash',
		'repasswd'=>'require|confirm:passwd',
		'email'	=>'email',
		'tel'	=>'mobile',
		'id'	=>'require|gt:1',
    ];
    
    protected $message  =   [
        'username.require' => '用户名必须',
        'username.max'     => '用户名最多不能超过20个字符',
        'username.min'     => '用户名不少于5字符',
        'passwd.require' => '密码必须',
		'passwd.min' => '密码必须6位以上',
		'email'				=>	'email格式错误',
		'tel'				=>	'手机号格式错误',
		'id.gt'				=>	'默认账号无法删除!!',
		'passwd.confirm'		=>'二次输入密码不相同',
		'repasswd.confirm'		=>'二次输入密码不相同',
		
    ];
    protected $scene = [
        'check'  =>  ['username','passwd'],
		'add'  =>  ['username','passwd','repasswd'],
		'edit'  =>  ['passwd','repasswd','email','tel'],
		'emptypwd'  =>  ['passwd','repasswd','email','tel'],
		'del'  =>  ['id'],
		'cue'	=> ['username','email','tel'],
    ];
	public function sceneEmptypwd()
	    {
	    	return $this->only(['passwd','repasswd','email','tel'])
				->remove('passwd','require')
				->remove('repasswd','require');
	    } 
	public function sceneCUE(){
	    	return $this->only(['username','email','tel'])
	            ->remove('username','require');
	}
}